package com.zhiyou.check.controller;

import com.zhiyou.check.pojo.SingnIn;
import com.zhiyou.check.service.SingnInService;
import com.zhiyou.common.pojo.Result;
import com.zhiyou.common.pojo.StateCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@org.springframework.web.bind.annotation.RestController()
@RequestMapping("/singnins")
public class SingnInController {

    @Autowired
    SingnInService singnInService;
    /**
     * 求出某个学生所有考勤时间  参数：学生ID
     */
    @GetMapping("/findBySid/{sid}")
    public Result findBySid(@PathVariable Integer sid){

        return new Result(true, StateCode.OK,"查询成功",singnInService.findBySid(sid));
    }

    /**
     *根据班级求出每个学生考勤总记录-     参数： 班级ID  考勤时间  2020-08
     */
    @GetMapping("/findByGid/{gid}/{date}")
    public Result findByGidAndByDate(@PathVariable Integer gid,@PathVariable String date){

        return new Result(true, StateCode.OK,"查询成功",singnInService.findByGidAndByDate(gid,date));
    }
    /**
     * 根据学生ID与年月份求出某个学生考勤总统计
     */
    @GetMapping("/findBySidAndDate/{sid}/{date}")
    public Result findBySidAndByDate(@PathVariable Integer sid,@PathVariable String date){

        return new Result(true, StateCode.OK,"查询成功",singnInService.findBySidAndByDate(sid,date));
    }

    /**
     * 添加学生入校考勤
     */
    @PostMapping(("/insert"))
    public Result insertEntryTime(SingnIn singnIn){
        singnInService.insertEntryTime(singnIn);
        return new Result(true, StateCode.OK,"添加成功");

    }


    /**
     *  添加学生离校考勤
     */
   @PostMapping("/update")
   public Result updateLeaveSchoolTime(SingnIn singnIn){
       singnInService.updateLeaveSchoolTime(singnIn);
       return new Result(true, StateCode.OK,"修改成功");
   }





}
